#include "myd_directx.h"

bool myd_directx::InitDX(void)
{
	_pD3D = Direct3DCreate9(D3D_SDK_VERSION);

	D3DDISPLAYMODE displayMode;
	
	HRESULT hr = _pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode);

	D3DPRESENT_PARAMETERS d3dPresentParameters;
	ZeroMemory(&d3dPresentParameters, sizeof(d3dPresentParameters));

	d3dPresentParameters.BackBufferFormat = displayMode.Format;
	d3dPresentParameters.Windowed = true;
	d3dPresentParameters.BackBufferCount = 1; 
	d3dPresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dPresentParameters.hDeviceWindow = 0; 
	d3dPresentParameters.Flags = 0;
	d3dPresentParameters.EnableAutoDepthStencil = TRUE;
	d3dPresentParameters.AutoDepthStencilFormat = D3DFMT_D24S8; 
	d3dPresentParameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
	d3dPresentParameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	hr = _pD3D->CreateDevice(D3DADAPTER_DEFAULT,
							 D3DDEVTYPE_HAL,
							 g_window.getHwnd(),
							 D3DCREATE_HARDWARE_VERTEXPROCESSING,
							 &d3dPresentParameters,
							 &_pDevice
							 );
	
	return true;
}

myd_directx::myd_directx(void)
{
}

myd_directx::~myd_directx(void)
{
}
